package com.sk.bilibili.view.fragment.member;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.sk.bilibili.adapter.vlayout.member.favorites.FavoritesAdapter;
import com.sk.bilibili.bean.Favorites;
import com.sk.bilibili.callBack.FavoritesClickCallBack;
import com.sk.bilibili.model.fragment.member.FavoritesModel;
import com.sk.bilibili.view.activity.CollectActivity;
import com.sk.bilibili.view.fragment.BaseListFragment;

import java.util.List;

public class FavoritesFragment extends BaseListFragment<FavoritesModel> implements FavoritesClickCallBack {

    private Integer memberId;
    
    public FavoritesFragment(Integer memberId) {
        this.memberId=memberId;
    }

    private FavoritesAdapter favoritesAdapter;

    @Override
    protected void afterSetView() {
        super.afterSetView();
        model.loadFavorites(memberId);
    }

    @Override
    protected void initAdapter(DelegateAdapter adapter) {
        favoritesAdapter = new FavoritesAdapter(getContext(), this);
        adapter.addAdapter(favoritesAdapter);
    }

    @Override
    public void onFavoritesClick(Integer id) {
        CollectActivity.start(getContext(),id);
    }

    public void loadFavoritesSuccess(List<Favorites> favorites) {
        favoritesAdapter.setData(favorites);
    }

}